package org.example.base;

import dev.langchain4j.data.message.AiMessage;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.output.Response;

/**
 * @Author codeYang
 * @Date 2025/3/16 17:03
 * @Version 1.0
 */
public class HelloWorld {

    public static void main(String[] args) {
        ChatLanguageModel chatLanguageModel = OpenAiChatModel.builder()
                .apiKey("demo")
                .modelName("gpt-4o-mini")
                .build();

        UserMessage userMessage = UserMessage.from("你叫什么?");

        Response<AiMessage> generate = chatLanguageModel.generate(userMessage);

        AiMessage aiMessage = generate.content();

        System.out.println("aiMessage" + aiMessage.text());

        UserMessage userMessage2 = UserMessage.from("重复一次");

        Response<AiMessage> generate1 = chatLanguageModel.generate(userMessage,aiMessage, userMessage2);

        System.out.println(generate1.content().text());


    }
}
